home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17337 < prev    next >
Encoding:
Text File  |  1996-08-05  |  844 b   |  40 lines

  1. Path: fet.tiasur.tomsk.su!Orchid!leha
  2. From: leha@Orchid.fet.tiasur.tomsk.su (Dirks Alexey)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Array of Funcions ??
  5. Date: 14 Apr 96 09:02:36 GMT
  6. Organization: TASUR
  7. Message-ID: <leha.829472556@Orchid>
  8. References: <4kgr2c$b99@news.dpi.udec.cl>
  9. NNTP-Posting-Host: orchid.fet.tiasur.tomsk.su
  10.  
  11. tarmstro@caleuche.inf.UDEC.CL (Thomas Armstrong Kobrich) writes:
  12.  
  13. >    I've the following problem. I Want to define an array
  14. >of functions (all with the same return value an the same parameters,
  15. >of course), named FuncArray, but I'dont know how to do it.
  16. >    The sentence:
  17.  
  18. I test this, and find it works:
  19.  
  20. #include <stdio.h>
  21. static void (*Func[2])(void);
  22. void func1()
  23. {
  24.     puts("func 1");
  25. }
  26. void func2()
  27. {
  28.     puts("func 2");
  29. }
  30. int main()
  31. {
  32.     int i;
  33.     Func[0] = func1;
  34.     Func[1] = func2;
  35.     for( i=0; i<2; i++ )
  36.     {
  37.         Func[i]();
  38.     }
  39. }
  40.